/*景区动态*/
Ext.define('qjtravel.view.Activity', {
    extend: 'Ext.Panel',
    xtype: 'activity',
    requires: [
        'Ext.List', 'Ext.TitleBar', 'Ext.plugin.PullRefresh', 'Ext.plugin.ListPaging'
    ],

    config: {
        layout: 'card',
        cls:"dv",
        items: [
            {
                xtype: 'titlebar',
                docked: 'top',
                title: '文化活动',
                ui:'dark',
                items: {
                    xtype: 'button',
                    text: '返回',
                    listeners: {
                        tap: function () {
                            window.localStorage.removeItem("homeClick");
                            Ext.Viewport.remove(this.up('activity'), true);
                        }
                    }
                }
            },
            {
                xtype: 'dataview',
                selectedCls: false,
                scrollable: true,
                store: 'News',
                emptyText:"<div style='width: 100%;text-align: center'>暂无活动</div>",
                id:"activityList"
            }
        ],
        listeners: {
            painted: function () {
                Ext.Viewport.unmask();
            },
            back: function () {
                window.localStorage.removeItem("homeClick");
                Ext.Viewport.remove(Ext.Viewport.getActiveItem(), true);
            },
            initialize: function (list) {
                var News = Ext.getStore('News');
                News.load({params: {ccid: '4'} });
                var bodyW=document.body.clientWidth;
                var imgW=bodyW*0.25;
                var imgH=imgW*0.75;
                var styleStr="float:left;width:"+imgW+"px;height:"+imgH+"px";
                var baseParam=bodyW>599?1:0.4;
                var styleStrDate="line-height:"+(imgH*baseParam)+"px;height: "+(imgH*0.5)+"px;text-align: right;"
                Ext.getCmp("activityList").setItemTpl("<div style='height: "+imgH+"px;'>" +
                    "<img src='{picurl}' style="+styleStr+" class='radius1'/>" +
                    "<div class='news_title font1 color2'>{name}</div>" +
                    "<div class='news_date font3 color1' style='"+styleStrDate+"'>{[Ext.Date.format(new Date(parseInt(values.lasttime) * 1000), 'Y-m-d')]}</div>" +
                    "</div>");
            },
            itemtap: function (list, index, element, record) {
                window.localStorage.setItem('NewsDetail_caid', record.getData().caid);
                Ext.Viewport.animateActiveItem('activityDetail', {type: 'slide', direction: 'left'});
            }
        }
    }
});


